Repository navigation
Conversation
Benchmark ResultsComparison of Open to see the benchmark resultsNo benchmark changes above ±5%. Generated by phpbench against commit 1e68f29 |
|
Hey, I think this needs a more thorough refactor, as some paths still quote things without calling the fixed method, such as |
|
@xHeaven wouldn't that be a separate follow-up PR? to keep the changes small and focused |
|
Keep them in the same PR :) |
|
This pull request is stale because it has been open for 30 days with no activity. |
|
This pull request was closed because it has been inactive for 1 day since being marked as stale. |
|
Is this ready to merge? |
|
Note This message is generated by an AI agent on behalf of @xHeaven. I think the earlier concern still stands. The helper change looks correct, but There’s also an issue in -- Before Query::compile():
"name` DESC --" ASC
-- After:
"name" DESC --" ASCThese issues predate this PR, but they leave the escaping fix incomplete. Could we cover those paths too, with tests checking the final compiled SQL? |
|
Yeah unfortunately it goes much deeper than this simple change. We can check how Eloquent and Doctrine solve this to get better ideas. |
Let's do that, I recommend broadening this PR if needed, rather than solving just part of the issue. Do you want to work on this (I presume it'll be a bit more substantial change) or should we take over here? |
|
@xHeaven Feel free to take over 👍 I no longer have the capacity to work on it |
|
Last time I checked it involved refactoring more stuff to pass |
Escape quote characters in
DatabaseDialect::quoteIdentifier()to prevent potential SQL injection when identifiers come from untrusted input.The method wraps an identifier in quote characters, but previously did not escape quote characters already inside it. This meant an identifier containing a quote could end its own quoting, causing the rest of the value to be treated as SQL instead of part of the identifier:
Doubling the quote character is the escaping format expected by MySQL/SQLite and PostgreSQL. This also matches how other frameworks handle identifier quoting, including Laravel's
Illuminate\Database\Grammar::wrapValueand Doctrine DBAL'sAbstractPlatform::quoteSingleIdentifier.Handling this at the dialect level means all call sites - relations, table aliases, migration statements, etc. - get the same protection without having to sanitise identifiers individually.
Testing
Added unit test at
packages/database/tests/Config/DatabaseDialectTest.php.